package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.CampCommunication;
import com.ruoyi.wechat.service.ICampCommunicationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营地交流Controller
 * 
 * @author ruoyi
 * @date 2024-12-25
 */
@RestController
@RequestMapping("/camp/communication")
public class CampCommunicationController extends BaseController
{
    @Autowired
    private ICampCommunicationService campCommunicationService;

    /**
     * 查询营地交流列表
     */
    @PreAuthorize("@ss.hasPermi('camp:communication:list')")
    @GetMapping("/list")
    public TableDataInfo list(CampCommunication campCommunication)
    {
        startPage();
        List<CampCommunication> list = campCommunicationService.selectCampCommunicationList(campCommunication);
        return getDataTable(list);
    }

    /**
     * 导出营地交流列表
     */
    @PreAuthorize("@ss.hasPermi('camp:communication:export')")
    @Log(title = "营地交流", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CampCommunication campCommunication)
    {
        List<CampCommunication> list = campCommunicationService.selectCampCommunicationList(campCommunication);
        ExcelUtil<CampCommunication> util = new ExcelUtil<CampCommunication>(CampCommunication.class);
        util.exportExcel(response, list, "营地交流数据");
    }

    /**
     * 获取营地交流详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:communication:query')")
    @GetMapping(value = "/{campcommunicationId}")
    public AjaxResult getInfo(@PathVariable("campcommunicationId") String campcommunicationId)
    {
        return success(campCommunicationService.selectCampCommunicationByCampcommunicationId(campcommunicationId));
    }

    /**
     * 新增营地交流
     */
    @PreAuthorize("@ss.hasPermi('camp:communication:add')")
    @Log(title = "营地交流", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CampCommunication campCommunication)
    {
        return toAjax(campCommunicationService.insertCampCommunication(campCommunication));
    }

    /**
     * 修改营地交流
     */
    @PreAuthorize("@ss.hasPermi('camp:communication:edit')")
    @Log(title = "营地交流", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CampCommunication campCommunication)
    {
        return toAjax(campCommunicationService.updateCampCommunication(campCommunication));
    }

    /**
     * 删除营地交流
     */
    @PreAuthorize("@ss.hasPermi('camp:communication:remove')")
    @Log(title = "营地交流", businessType = BusinessType.DELETE)
	@DeleteMapping("/{campcommunicationIds}")
    public AjaxResult remove(@PathVariable String[] campcommunicationIds)
    {
        return toAjax(campCommunicationService.deleteCampCommunicationByCampcommunicationIds(campcommunicationIds));
    }
}
